package forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class ProcessNotStartedInsertForm extends ActionForm {

	private static final long serialVersionUID = 1L;

	private String username = null;
	private String password = null;
	private String email = null;

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * Reset all properties to their default values.
	 * 
	 * @param mapping
	 *            The mapping used to select this instance
	 * @param request
	 *            The servlet request we are processing
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		setUsername(null);
		setPassword(null);
	}

	/**
	 * Validate the input data. If validation fails, then report the errors in
	 * students.jsp, and specifically where <html:errors/> is located.
	 * 
	 * @param mapping
	 *            The mapping used to select this instance
	 * @param request
	 *            The servlet request we are processing
	 */
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {

		ActionErrors errors = new ActionErrors();

		if ((username == null) || (username.length() < 1))
			errors.add("firstMsgTag1", new ActionMessage("errors.required",
					"Username"));

		if ((password == null) || (password.length() < 1))
			errors.add("lastMsgTag1", new ActionMessage("errors.required",
					"Password"));
		
		if ((email == null) || (email.length() < 1))
			errors.add("lastMsgTag1", new ActionMessage("errors.required",
					"Email"));

		return errors;
	}

}
